<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>{$theme['title']}-支付确认</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
    <link rel="stylesheet" type="text/css" href="{$_G['URL']['EDUCATION_STATIC_PATH']}/css/reset.css">
    <link rel="stylesheet" type="text/css" href="{$_G['URL']['EDUCATION_STATIC_PATH']}/css/swiper.min.css">
    <link rel="stylesheet" type="text/css" href="{$_G['URL']['EDUCATION_STATIC_PATH']}/css/style.css">
    <script src="{$_G['URL']['EDUCATION_STATIC_PATH']}/js/screen.js"></script>
    <script src="{$_G['URL']['EDUCATION_STATIC_PATH']}/js/jquery.js"></script>
    <script src="{$_G['URL']['EDUCATION_STATIC_PATH']}/js/swiper.min.js"></script>
    <!-- 引入 Vue 和 Vant 的 JS 文件 -->
    <script src="https://css2020.yixuan.net/2020css/beilai/js/vue@next.js?v=1"></script>
    <script src="https://css2020.yixuan.net/2020css/beilai/js/vant.min.js?v=1"></script>
    <script src="{$_G['URL']['LOTTERY_CSS']}lottery/js/layer/layer.js"></script>
<!--    <script src="{$_G['URL']['YX2020_CSS']}js/vconsole.min.js"></script>-->
<!--    <script> var vConsole = new VConsole(); </script>-->
    <style>
        .lessonFooter{
            height: 1rem;
            padding-top: 0;
        }
        .lessonFooter a.nextStep{
            line-height: .7rem;
            margin-top: .14rem;
        background: linear-gradient(90deg, {$config['formcolorhead']} 15.44%, {$config['formcolortop']} 90.59%);
        }
    </style>
</head>
<body class="grayBox">
{if !$can_new_select}
<div class="payForm">
    <h3>报名信息</h3>
    <ul>
        {loop $form $item}
        <!--    文本     -->
        {if $item['type'] == 'txt'}
        <li>
            <p>{$item['title']}</p>
            {if $item['name'] == 'mobiletext'}
            <input type="number" name="{$item['name']}" id="{$item['name']}" placeholder="{$item['placeholder']}" />
            {else}
            <input type="text" name="{$item['name']}" id="{$item['name']}" placeholder="{$item['placeholder']}" />
            {/if}
        </li>
        {/if}
        <!--   日期     -->
        {if $item['type'] == 'date'}
        <li>
            <p>{$item['title']}</p>
            <input type="date" placeholder="{$item['placeholder']}" name="{$item['name']}" id="{$item['name']}" />
        </li>
        {/if}
        <!--   数字     -->
        {if $item['type'] == 'number'}
        <li>
            <p>{$item['title']}</p>
            <input type="number" placeholder="{$item['placeholder']}" name="{$item['name']}" id="{$item['name']}" />
        </li>
        {/if}
        <!--   手机号     -->
        {if $item['type']== 'mobile'}
        <li>
            <p>{$item['title']}</p>
            <input type="mobile" placeholder="{$item['placeholder']}" name="{$item['name']}" id="{$item['name']}" />
        </li>
        {/if}
        <!--   单选     -->
        {if $item['type']=='radio'}
        <li>
            <p>{$item['title']}</p>
            <input type="hidden" class="edu-radio" name="{$item['name']}" id="{$item['name']}">
            <div class="choseSex" data-id="{$item['name']}">
                {loop $item['val'] $row}
                <span>{$row}</span>
                {/loop}
            </div>
        </li>
        {/if}
        <!--   下拉     -->
        {if $item['type']=='select'}
        <li>
            <p>{$item['title']}</p>
            <input type="text" hidden name="{$item['name']}" id="{$item['name']}">
            <div class="choseSlide">
                请选择{$item['title']}
            </div>
            <div class="choseSelect">
                <ul>
                    {loop $item['val'] $row}
                    <li>{$row}</li>
                    {/loop}
                </ul>
                <span class="closeChose">取消</span>
            </div>
        </li>
        {/if}
        {/loop}
    </ul>
</div>
{/if}
<div class="signInfor courseInfo">
    <h2>{$course_other_name}信息</h2>
    <ul>
    </ul>
</div>
<div class="signInfor giftInfo" style="display: none;">
    <h2>{$gift_other_name}信息</h2>
    <ul>
    </ul>
</div>
{if $theme['yixuanbanquan'] != '1'}
<div class="metro_container content" style="text-align:center; padding:10px 0px 0px";>
    <a style="font-size:0.2rem;" href="{php echo empty($theme['USERURL'])?$system['s']['yixuanurl']:$theme['USERURL'];}">{php echo empty($theme['USERJISHU'])?$system['s']['yixuanjishu']:html_entity_decode($theme['USERJISHU'], ENT_QUOTES);}</a>
</div>
{/if}
<div class="h160"></div>
<div class="lessonFooter">
    {if $theme_status==1}
        {if $can_new_select}
        <a href="javascript:void(0)" onclick="confirm()" class="nextStep">确认提交</a>
        {else}
        <a href="javascript:void(0)" id="topay" class="nextStep" style="color: {$config['formcolorcentertext']}">立即报名</a>
        {/if}
    {else}
    <a href="javascript:void(0)" class="nextStep" style="color: {$config['formcolorcentertext']}">活动已结束</a>
    {/if}

    <p class="zprice">总计<span class="num">¥<b>{$price_info['now_price']}</b></span>{if $price_info['coupon']}<span style="font-size: 10px;color: gray;">(已使用优惠{$price_info['coupon']}元)</span>{/if}</p>
</div>
<!--下拉选择-->
<div id="screen"></div>
<div class="choseSelect">
    <ul>
        <li>选项1</li>
        <li>选项2</li>
        <li>选项3</li>
    </ul>
    <span class="closeChose">取消</span>
</div>
</body>
<script type="text/javascript">
    let course_address_str=localStorage.getItem("course_address")||[];
    let gift_ids=localStorage.getItem("gift_ids")||[];
    let giftStr=localStorage.getItem("giftStr")||[];
    if(!course_address_str) {
        window.location.href = go(-2);
    }
    if(!gift_ids) {
        window.location.href = go(-1);
    }
    // 课程数据回显
    let course_address = JSON.parse(course_address_str);
    let courseStr = '';
    for(let i = 0; i < course_address.length; i++) {
        courseStr += `<li>
            <div class="signImg">
                <img src="${course_address[i].top_img}" >
            </div>
            <div class="signTxt">
                <p>${course_address[i].name}</p>
                <span>${course_address[i].shangjia_name}</span>
            </div>
        </li>`
    }
    $('.courseInfo ul').html(courseStr);
    // 赠品数据回显
    if (giftStr && giftStr.length>0){
        let giftObj = JSON.parse(giftStr);
        let giftHTML = '';
        for (let i = 0; i < giftObj.length; i++) {
            giftHTML += `<li>
            <div class="signImg">
                <img src="${giftObj[i].top_img}" >
            </div>
            <div class="signTxt">
                <p>${giftObj[i].name}</p>
                <span>价值：${giftObj[i].price}</span>
            </div>
        </li>`
        }
        $('.giftInfo ul').html(giftHTML);
        $('.giftInfo').show();
    }
    let confirm_course_address=[];
    for(let i=0;i<course_address.length;i++){
        confirm_course_address.push({
            shangjia_id:course_address[i].shangjia_id,
            courseid:course_address[i].courseid,
            address:course_address[i].address
        });
    }
    function confirm(){
        let confirm_course_address=[];
        for(let i=0;i<course_address.length;i++){
            confirm_course_address.push({
                shangjia_id:course_address[i].shangjia_id,
                courseid:course_address[i].courseid,
                address:course_address[i].address
            });
        }
        $.ajax({
            method:"POST",
            url:"/{php echo createMobileUrl('wx', array('themeid'=>$themeid,'r'=>'education.index.reloadInfo','from'=>'mobile'));}",
            data:{
                course_address:confirm_course_address,
                gift_ids:gift_ids
            },
            dataType:'json',
            success:function(res){
                console.log(res)
                let error = res.error;
                let msg = res.msg;
                if (error==1){
                    layer.msg(msg);
                    return
                }else{
                    layer.msg(msg,{time:2000},function () {
                       window.location.href = "/{php echo createMobileUrl('wx', array('themeid'=>$themeid,'r'=>'education.index.Mine','from'=>'mobile'));}";
                    });
                }
            }
        })
    }

    /*性别选择*/
    $('.choseSex span').click(function(e){
        let tmp_id = $(this).parent().attr('data-id');
        var temp_val = $(this).html();
        $("#"+tmp_id).val(temp_val);
        $(this).addClass('cur').siblings().removeClass('cur');
    })
    $('.nextStep').click(function(){
        $('.paySuccess').fadeIn();
    })
    //自定义下拉
    $('.choseSlide').click(function(){
        $('#screen').fadeIn();
        // $('.choseSelect').animate({'bottom':'0'},500);
        $(this).next().animate({'bottom': '0'}, 500);
    })
    $('#screen').click(function(){
        $('#screen').fadeOut();
        // $('.choseSelect').animate({'bottom':'-120%'},500);
    })
    $('.closeChose').click(function (){
        $(this).parent().animate({bottom: '-120%'}, 500);
    })
    $('.choseSelect li').click(function(){
        var choseVal = $(this).html();
        $('#screen').fadeOut();
        $(this).parents('.choseSelect').animate({'bottom':'-120%'},500);
        $(this).parents('.choseSelect').prev().html(choseVal)
        $(this).parents('.choseSelect').prev().prev().val(choseVal)
        $(this).parents('.choseSelect').prev().addClass('chosed')
    })
    //多选
    $('.moreChose span').click(function(){
        var num = $('.moreChose .cur').length;
        if($(this).hasClass('cur')){
            $(this).removeClass('cur')
        }else{
            $(this).addClass('cur')
            /*if(num>=3){
                alert('最多只可选择三项')
            }else{
                $(this).addClass('cur')
            }*/

        }


    })
</script>
{include file='base/addlog'}
{include file='../../plugin/education/template/mobile/tips'}
{include file='../../plugin/education/template/mobile/wxpay'}
